<?php

/**
 * This is the model class for table "xman_user_rate".
 *
 * The followings are the available columns in table 'xman_user_rate':
 * @property integer $user_rate_id
 * @property integer $user_rate_project_id
 * @property integer $user_rate_user_id
 * @property double $user_rate_cost
 *
 * The followings are the available model relations:
 * @property User $userRateUser
 * @property Project $userRateProject
 */
class UserRate extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return UserRate the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'xman_user_rate';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('user_rate_project_id, user_rate_user_id, user_rate_cost', 'required'),
			array('user_rate_project_id, user_rate_user_id', 'numerical', 'integerOnly'=>true),
			array('user_rate_cost', 'numerical'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('user_rate_id, user_rate_project_id, user_rate_user_id, user_rate_cost', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'userRateUser' => array(self::BELONGS_TO, 'User', 'user_rate_user_id'),
			'userRateProject' => array(self::BELONGS_TO, 'Project', 'user_rate_project_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'user_rate_id' => 'User Rate',
			'user_rate_project_id' => 'User Rate Project',
			'user_rate_user_id' => 'User Rate User',
			'user_rate_cost' => 'User Rate Cost',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('user_rate_id',$this->user_rate_id);
		$criteria->compare('user_rate_project_id',$this->user_rate_project_id);
		$criteria->compare('user_rate_user_id',$this->user_rate_user_id);
		$criteria->compare('user_rate_cost',$this->user_rate_cost);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}